package com.cjh.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RoutingDirectConsumer {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue("queue1"),
                    key = {"info", "warm"},
                    exchange = @Exchange(name = "directs", type = ExchangeTypes.DIRECT)
            )})
    public void receive1(String message) {
        System.out.println("消费者【1】接收到消息：" + message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue("queue2"),
                    key = {"debug", "error"},
                    exchange = @Exchange(name = "directs", type = ExchangeTypes.DIRECT)
            )})
    public void receive2(String message) {
        System.err.println("消费者【2】接收到消息：" + message);
    }
}